{% extends "base.html" %}
{% block head %}
    {{ super() }}
    <link rel="stylesheet" href="{{ url_for('static', filename='3rd/ui/remodal.css')}}">
    <link rel="stylesheet" href="{{ url_for('static', filename='3rd/ui/remodal-default-theme.css')}}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/book-detail.css')}}">
{% endblock %}
{% block content %}
    {{ super() }}
    <div class="row book-container">
        <div class="col-md-2">
            <img class="book-img" src="{{ book.image }}"/>
        </div>
        <div style="margin-left: 30px;" class="col-md-5 flex-vertical">
            <div>
                <h4>{{ book.title }}</h4>
            </div>
            <div class="description-font-margin">
                <div>
                    <span>作者:</span>
                    <span>{{ book.author }}</span>
                </div>
                <div>
                    <span>出版社:</span>
                    <span>{{ book.publisher }}</span>
                </div>
                <div>
                    <span>出版年：</span>
                    <span>{{ book.pubdate }}</span>
                </div>
                <div>
                    <span>页数：</span>
                    <span>{{ book.pages }}</span>
                </div>
                <div>
                    <span>定价：</span>
                    <span>{{ book.price }}</span>
                </div>
                <div>
                    <span>精装：</span>
                    <span>{{ book.binding }}</span>
                </div>
                <div>
                    <span>ISBN：</span>
                    <span id="isbn">{{ book.isbn }}</span>
                </div>
                {% if wishes.total or gifts.total %}
                    <div class="color-count">
                        <span>{{ wishes.total }}人想要 / </span>
                        <span>{{ gifts.total}}人可赠送</span>
                    </div>
                {% endif %}
            </div>
        </div>
    </div>
    <div style="margin-top:30px;" class="row">
        {% if not has_in_gifts and not has_in_wishes %}
            <div class="col-md-1">
                <a class="btn btn-outline"
                   href="#modal">
                    赠送此书
                </a>
            </div>
            <div style="margin-left:30px;" class="col-md-1">
                <a class="btn btn-outline"
                   href="{{ url_for('web.save_to_wish', isbn=book.isbn) }}">
                    加入到心愿清单
                </a>
            </div>
        {% elif has_in_wishes %}
            <div class="col-md-3">
                <span class="bg-info">已添加至心愿清单</span>
            </div>
        {% else %}
            <div class="col-md-3">
                <span class="bg-info">已添加至赠送清单</span>
            </div>
        {% endif %}
    </div>
    <div style="margin-top: 30px;" class="row">
        <div class="col-md-2"><span class="description-title">内容简介</span></div>
    </div>
    <div style="margin-top:15px;" class="row">
        <div class="col-md-11">
            <p class="description-font">{{ book.summary }}</p>
        </div>
    </div>
    {% if gifts.total!= 0 and not has_in_gifts %}
        <div style="margin-top:30px;" class="row">
            <div class="col-md-3"><span class="description-title">向他们请求此书</span></div>
        </div>
        <hr style="margin-top:5px;"/>
        {% for gift in gifts.trades %}
            <div style="margin-top:30px;" class="row">
                <div class="col-md-1">
                    {{ gift.user_name }}
                </div>
                <div class="col-md-2 description-font">
                    上传于{{ gift.time }}
                </div>
                <div class="col-md-2">
                    <a class="btn-normal"
                       href="{{ url_for('web.send_drift', gid=gift.id) }}">向他请求此书</a>
                </div>
            </div>
        {% endfor %}
    {% endif %}
    {% if wishes.total != 0 and has_in_gifts %}
        <div style="margin-top:30px;" class="row">
            <div class="col-md-3"><span class="description-title">向他们赠送此书</span></div>
        </div>
        <hr style="margin-top:5px;"/>
        {% for wish in wishes.trades %}
            <div style="margin-top:30px;" class="row">
                <div class="col-md-1">
                    {{ wish.user_name }}
                </div>
                <div class="col-md-2 description-font">
                    上传于{{ wish.time }}
                </div>
                <div class="col-md-2">
                    <a class="btn-normal"
                       href="{{ url_for('web.satisfy_wish', wid=wish.id, isbn=[book.isbn]) }}">向他赠送此书</a>
                </div>
            </div>
        {% endfor %}
    {% endif %}
    <div class="remodal" data-remodal-id="modal" role="dialog"
         aria-labelledby="modal1Title" aria-describedby="modal1Desc"
         data-remodal-options="closeOnOutsideClick: false">
        <button data-remodal-action="close" class="remodal-close"
                aria-label="Close"></button>
        <div>
            <h5 class="diag-title">
                您确定拥有《{{ book.title }}》这本书吗？</h5>
            <p id="modal1Desc" class="description-font">
                如果您不想赠送此书，或者没有这本书，请不要随意发布虚假信息。谢谢你的支持和理解。
            </p>
        </div>
        <br>
        <button data-remodal-action="confirm" class="remodal-confirm">确定赠送</button>
        <button data-remodal-action="cancel" class="remodal-cancel">不，算了</button>
    </div>
{% endblock %}
{% block scripts %}
    {{ super() }}
    <script src="{{ url_for('static', filename='3rd/remodal.min.js') }}"></script>
    <script src="{{ url_for('static', filename='js/book-detail.js') }}"></script>
{% endblock %}